package base;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.android.tu.loadingdialog.LoadingDailog;
import com.githang.statusbar.StatusBarCompat;
import com.hichip.campro.R;

import butterknife.ButterKnife;
import custom.dialog.Effectstype;
import custom.dialog.WarningDialogBuilder;
import utils.DialogUtils;

public abstract class HiLandScapeActivity extends AppCompatActivity {

    public Dialog mJhLoading;
    public Dialog mLoadDialoging;
    public AlertDialog.Builder mDlgBuilder;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //绑定当前activity对象
        setContentView(setLayoutId());
//        //设置状态栏为白色底 状态栏字体为黑色
       StatusBarCompat.setStatusBarColor(this, Color.parseColor("#00FFFFFF"), true);
        ButterKnife.bind(this);
        init(savedInstanceState);
    }

    /**
     * 设置资源布局
     */
    protected abstract int setLayoutId();

    protected abstract void init(@Nullable Bundle savedInstanceState);

    @Override
    public void finish() {
        super.finish();
       // overridePendingTransition(R.anim.out_to_right, R.anim.in_from_left);
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        super.startActivityForResult(intent, requestCode);
        overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
    }

    @Override
    public void startActivity(Intent intent) {
        super.startActivity(intent);
        overridePendingTransition(R.anim.in_act_my, R.anim.out_act_my);
    }


    /**
     * 菊花转的dialog
     */
    public void showjuHuaDialog() {
        if (mJhLoading == null) {
            mJhLoading = DialogUtils.createLoadingDialog(this, true);
        }
        mJhLoading.show();
    }

    /**
     * 菊花转的dialog
     */
    public void dismissjuHuaDialog() {
        if (mJhLoading != null) {
            mJhLoading.dismiss();
            mJhLoading=null;
        }
    }

    // loading  加载框显示
    public void showLoadDialog(String msg, boolean isOutside, boolean isCance) {
        if(mLoadDialoging==null){
            LoadingDailog.Builder loadBuilder = new LoadingDailog.Builder(this).setMessage(msg).setCancelable(isCance).setCancelOutside(isOutside);
            mLoadDialoging = loadBuilder.create();
            if(!this.isFinishing()){
                mLoadDialoging.show();
            }
        }else {
            if(!this.isFinishing()){
                mLoadDialoging.show();
            }
        }
    }

    // loading  加载框隐藏
    public void dissmissLoadDialog() {
        if (mLoadDialoging != null) {
            mLoadDialoging.dismiss();
            mLoadDialoging=null;
        }
    }

}
